package com.pri.chat.nim.session.extension;

import com.alibaba.fastjson.JSONObject;

/**
 * 类描述：自定义图文
 *
 * @author mhd
 */
public class GiftAttachment extends CustomAttachment {
    private final String KEY_DESCRIBE = "describe";
    private final String KEY_IMAGE_URL = "image_url";
    private final String KEY_MONEY = "money";

    public String getDescribe() {
        return describe;
    }

    public void setDescribe(String describe) {
        this.describe = describe;
    }

    public String getImageUrl() {
        return imageUrl;
    }

    public void setImageUrl(String imageUrl) {
        this.imageUrl = imageUrl;
    }

    public int getMoney() {
        return money;
    }

    public void setMoney(int money) {
        this.money = money;
    }

    // 图文消息的描述，可以为空
    private String describe;
    // 图文消息的图片
    private String imageUrl;
    // 礼物价格
    private int money;

    public GiftAttachment() {
        super(CustomAttachmentType.Gift);
    }

    @Override
    protected void parseData(JSONObject data) {
        describe = data.getString(KEY_DESCRIBE);
        imageUrl = data.getString(KEY_IMAGE_URL);
        money = data.getInteger(KEY_MONEY);
    }

    @Override
    protected JSONObject packData() {
        JSONObject data = new JSONObject();
        data.put(KEY_DESCRIBE, getDescribe());
        data.put(KEY_IMAGE_URL, getImageUrl());
        data.put(KEY_MONEY,getMoney());
        return data;
    }
}
